package drds.binlog.database_driver.packets.client;

import drds.binlog.common.Authors;
import drds.binlog.database_driver.packets.CommandPacket;
import drds.common.Author;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * quit cmd
 */
@Author(name = Authors.LI_YANG)
public class QuitCommandPacket extends CommandPacket
{

    public static final byte[] QUIT = new byte[]{1, 0, 0, 0, 1};

    public QuitCommandPacket()
    {
        setCommand((byte) 0x01);
    }

    @Override
    public void fromBytes(byte[] bytes) throws IOException
    {

    }

    @Override
    public byte[] toBytes() throws IOException
    {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byteArrayOutputStream.write(getCommand());
        byteArrayOutputStream.write(QUIT);
        return byteArrayOutputStream.toByteArray();
    }

}
